<extend name="Layout/application"/>

<block name="content">
    <div class="row">
        <div class="col-md-12">

            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>栏目管理</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">栏目管理</div>
                        <div class="panel-body">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                <tr>
                                    <th>#</th>
                                    <th>名称</th>
                                    <th>排序</th>
                                    <th>操作</th>
                                </tr>
                                </tr>
                                </thead>
                                <tbody>
                                <form method="post" action="sort_order" class="form">
                                    <volist name="categories" id="category">
                                        <tr>
                                            <td>{{$category.id}}</td>
                                            <td>{{$category.name}}</td>
                                            <input type="hidden" name="id[]" value="{{$category.id}}">
                                            <td><input type="text" name="sort_order[]" value="{{$category.sort_order}}">
                                            </td>
                                            <td>
                                                <a href="{{:U('edit',array('id'=>$category['id']))}}"
                                                   data-toggle="modal" data-target="#edit_categoryModal"
                                                   class="edit"><span class="glyphicon glyphicon-pencil"></span></a>
                                                <a href="{{:U('destory',array('id'=>$category['id']))}}"> <span
                                                        class="glyphicon glyphicon-trash"></span></a>
                                            </td>
                                        </tr>
                                        <volist name="category.children" id="c">
                                            <tr>
                                                <td>{{$c.id}}</td>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{$c.name}}</td>
                                                <td><input type="text" value="{{$c.sort_order}}"></td>
                                                <td>
                                                    <a href="{{:U('edit',array('id'=>$c['id']))}}" data-toggle="modal"
                                                       data-target="#edit_categoryModal"
                                                       class="edit"><span class="glyphicon glyphicon-pencil"></span></a>
                                                    <a href="{{:U('destory',array('id'=>$c['id']))}}"> <span
                                                            class="glyphicon glyphicon-trash"></span></a>
                                                </td>
                                            </tr>
                                        </volist>
                                    </volist>

                                </form>

                                </tbody>
                            </table>

                        </div>
                        <div >
                            {{$page}}
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="list-group">
                        <a href="{{:U('create')}}" class="list-group-item list-group-item-info ">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>
                        <a href="{{:U('sort_order')}}" class="list-group-item list-group-item-info sort_order">
                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 排序 (sort)
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <block name="js">
        <script>
            $(function () {
                $('.sort_order').click(function () {
                    $('.form').submit();
                })
            })
        </script>
    </block>

</block>